package com.yanqu.road.server.cmd.activity.summergames.fromcross;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.enums.eMailType;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SummerGamesProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.property.PropertyHelper;

import java.math.BigInteger;
import java.util.Date;

@Cmd(code = Protocol.S_SUMMER_GAMES_EXCHANGE_CANCEL_FROM_CROSS, desc = "取消申请(跨服返回)")
public class SummerGamesCancelExchangeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        SummerGamesProto.SummerGamesCancelExchangeRespMsg respMsg = SummerGamesProto.SummerGamesCancelExchangeRespMsg.parseFrom(packet.getBytes());

//        String language = "";
//        UserInfo userInfo = UserMgr.getUserInfo(player.getUserId());
//        if(userInfo != null){
//            language = userInfo.getLanguage();
//        }
//        String mailTitle = ServerLanguageMgr.getContent(MailManager.SUMMER_GAMES_MAIL_TITLE_4, language);
//        String mailContent = ServerLanguageMgr.getContent(MailManager.SUMMER_GAMES_CONTENT_4, language);
//        //邮件奖励
//        MailManager.sendMail(packet.getPlayerId(), 0, eMailType.SYSTEM.getValue(), respMsg.getInfo().getProvideId() + "=1", mailContent, mailTitle, new Date());
        player.getModule(CurrencyModule.class).addCurrency(PropertyHelper.parseGoodsToString(respMsg.getInfo().getProvideId(), BigInteger.ONE),
                eLogMoneyType.SummerGamesActivity, eLogMoneyType.SummerGamesActivityExchangeBack);
        player.sendPacket(Protocol.U_SUMMER_GAMES_EXCHANGE_CANCEL, respMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
